﻿/*************************************************************
 * <copyright file="OPQueryPage.xaml.cs" company="O-RID">
 *     Copyright (c)2010 O-RID Co.,Ltd.
 * </copyright>
 * <author>Li Dawei Zhang Jun</author>
 * <summary>
 *     ***OP别期间别查询***
 *
 *     引用服务：WCFServers.WCFOPDurEntrySpeedQureryRef
 *     服务功能：数据查询
 *   
 *     引用服务：WCFLog4Ref.WCFLog4Client
 *     服务功能：记录日志
 *
 * (界面)StackPanel的控件名和TextBox控件名相同
 *       Button与StackPanel的名称相同
 *       
 *          作成日：06/22/2010
 * </summary>
 *  ***********************************************************
*/
namespace Orid.Management.Statistics.OperatorUnitMangement.ProductionRelated.OPDurationQuery
{
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using Orid.Management.Statistics.OperatorUnitMangement.Common.SearchCtrl;
    using System.Windows;
    
    /// <summary>
    /// 
    /// </summary>
    public partial class OPQueryPage : Page
    {
        bool isExpanded = false;

        /// <summary>
        /// 
        /// </summary>
        public OPQueryPage()
        {
            InitializeComponent();

        }

        // 当用户导航到此页面时执行。
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            SelAllContainer selallcontainer = new SelAllContainer();

            OPQueryControl datagridcontrl = new OPQueryControl(selallcontainer);

            this.bOPDurationQuery.Child = selallcontainer;

            this.bOPDurationContent.Child = datagridcontrl;

            selallcontainer.accoridon.SelectedItemsChanged -= new System.Collections.Specialized.NotifyCollectionChangedEventHandler(accoridon_SelectedItemsChanged);
            selallcontainer.accoridon.SelectedItemsChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(accoridon_SelectedItemsChanged);
            IsExpanded();

        }

        /// <summary>
        /// accoridon 选择ITME事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void accoridon_SelectedItemsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            IsExpanded();
        }

        /// <summary>
        /// 判断 accoridon 收缩或展开时，DATAGRID的位置
        /// </summary>
        void IsExpanded()
        {
            if (isExpanded == true)
            {
                this.accoridonRow.Height = new GridLength(125);
                this.griddataRow.Height = new GridLength(10, System.Windows.GridUnitType.Star);
            }
            else
            {
                this.accoridonRow.Height = new GridLength(25);
                this.griddataRow.Height = new GridLength(10, System.Windows.GridUnitType.Star);
            }
            this.isExpanded = !this.isExpanded;

        }


    }
}
